package mars.ns.core
import mars.ns.HasState
import java.io.Serializable

/**
 * A link connects a node to a Node
 * Specified by a LinkType
 */
class Link(node: Node, linkType: LinkType) extends Equals with Serializable {
    // The object the link is going to
    def getLinkedTo(): Node = node
    // the type of relation between the objects
    def getType(): LinkType = linkType
    override def toString = linkType.toString + " -> " + node.toString

    // a link is unique by linkedTo and linkType
    override def canEqual(other: Any): Boolean = other match {
        case null => false
        case o : Link => this.getLinkedTo.canEqual(o.getLinkedTo) && this.linkType.canEqual(o.getType)
        case _ => false
    }
}